//
//  MYHomeViewCell.swift
//  NewMicroblog
//
//  Created by apple on 2016/10/26.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit

class MYHomeViewCell: UITableViewCell {
    
    var bottomViewTopCons: Constraint?
    var statusViewModel: MYStatusViewModel?{
        didSet{
        topView.statusViewModel = statusViewModel
           bottomViewTopCons?.uninstall()
            if statusViewModel?.listModel?.retweeted_status == nil {
                
                bottomView.snp_updateConstraints(closure: { (make) in
                    self.bottomViewTopCons = make.top.equalTo(topView.snp_bottom).constraint
                    reweetView.isHidden = true
                })

            }else{
                reweetView.statusViewModel = statusViewModel
                bottomView.snp_updateConstraints(closure: { (make) in
                    self.bottomViewTopCons = make.top.equalTo(reweetView.snp_bottom).constraint
                })
                reweetView.isHidden = false

                
                }
            }
        
        }
    

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    /// 设置UI界面
    private func setupUI(){
        backgroundColor = UIColor(white: 237/255, alpha: 1)
       contentView.addSubview(topView)
        contentView.addSubview(reweetView)
        contentView.addSubview(bottomView)
//        reweetView.backgroundColor = UIColor.red
//        topView.backgroundColor = UIColor.yellow
        topView.snp_makeConstraints { (make) in
            make.left.right.equalTo(contentView)
//            make.height.equalTo(50)
            make.top.equalTo(contentView).offset(8)
            
        }
        reweetView.snp_makeConstraints { (make) in
            make.top.equalTo(topView.snp_bottom)
            make.left.right.equalTo(contentView)
//            make.height.equalTo(100)
        }
        bottomView.snp_makeConstraints { (make) in
            self.bottomViewTopCons = make.top.equalTo(reweetView.snp_bottom).constraint
            make.left.right.equalTo(contentView)
            make.height.equalTo(35)
            make.bottom.equalTo(contentView)
        }
        
        
    }
    
    private lazy var topView:MYHomeTopView = MYHomeTopView()
    private lazy var reweetView:MYHomeReweetView = MYHomeReweetView()
    private lazy var bottomView:MYStatusBottomView = MYStatusBottomView()
    
}
